#pragma once

//#include <d3d.h> // RECT
#include "CircleCollisionInfo.h"
#include "ObjectManager.h"

#include "../SGD Wrappers/SGD_Math.h"
using namespace std;

enum CollisionSide {TOP,BOTTOM,LEFT,RIGHT,NONE};

//////////////////////////////////////////////////
// Forward Declarations:
class GameObject;

// A structure for storing the info from a collision.
struct CollisionInfo
{
	RECT Overlap;
	tVector2D toCollider;
	CollisionSide Side;
};

// A structure for storing the info from a linecast.
struct LinecastInfo
{
	float Distance;
	tVector2D point;
	GameObject* HitObject;
	CollisionSide side;

	// Constructor
	LinecastInfo(void);

	//////////////////////////////////////////////////
	// Accessors:
	GameObject* GetObjectHit() const {return HitObject;};
	float GetDistance() const {return Distance;};
};

class Physics
{
	static float Gravity;

	// Constructor
	Physics(void);

	// Destructor
	~Physics(void);
public:
	static tVector2D LineCollision( tVector2D CastLineStart, tVector2D CastLineEnd, tVector2D LineTwoStart, tVector2D LineTwoEnd, bool* didCollide );

public:
	//NOTE: All Physics functions are called statically via SRO(Physics::)
	static bool BoxToBox(CollisionInfo &collisionInfo, RECT rect1, RECT rect2);
	static bool BoxToCircle(CircleCollisionInfo collisionInfo, RECT rect, RECT circle);
	static float GetGravity() {return Gravity;};
	static bool LineCast(LinecastInfo &linecastInfo, float distance, tVector2D StartingPoint,
				tVector2D direction, const char* ignoreTag);
	static bool LineCast(LinecastInfo &linecastInfo, float distance, tVector2D StartingPoint,
				tVector2D direction, GameObject* ignoreObj);
	static bool Physics::LineCast(LinecastInfo &linecastInfo, float distance, tVector2D StartingPoint,
				tVector2D direction, vector<GameObject*>& ignoreVec);
	static RECT UpdateColRect(RECT& ColRect, int PosX, int PosY);
	static float Distance(const tVector2D& point1, const tVector2D& point2);
	static void RotatePoint(float centerX, float centerY, float& pointX, float& pointY, float angle);
	static void RotatePoint(tVector2D center, tVector2D& point, float angle);
	// Author:
	//	- Joshua Bramer
	// Description:
	//	- Calculate the center of a rectangle.
	// Parameters:
	//		box	- The box to calculate the center point of.
	// Return: tVector2D
	//		- The center point of the box.
	static tVector2D GetCenterPoint(const RECT& box);
};

